<template>
  <el-form-item v-bind="$attrs"
                :label="label"
                :prop="prop"
                tabindex="0"
                style="outline: none">
    <slot></slot>
  </el-form-item>
</template>

<script>
export default {
  name: 'KFormItem',
  inheritAttrs: false,
  props: {
    label: String,
    prop: String,
    validate: Array
  },
  mounted () {
    if (this.validate) {
      this.$root.$emit('k-form-add-validate', this)
    }
    this.$nextTick(() => {
      this.$el.onfocus = () => {
        let els = this.$el.querySelector('input,textarea,select')
        if (els) {
          if (els.id && els.id.indexOf('ke-editor') > -1) {
            // iframe
            let els = this.$el.querySelector('iframe')
            if (els) {
              els.contentWindow.document.getElementById('tinymce').focus()
            }
          } else {
            els.focus()
          }
        }
      }
    })
  }
}
</script>

<style scoped>

</style>
